package com.baizhi.cmfz.service.impl;


import com.baizhi.cmfz.annotation.AddCacheAnnotation;
import com.baizhi.cmfz.annotation.LogAnnotation;
import com.baizhi.cmfz.dao.CmfzLogDao;
import com.baizhi.cmfz.entity.CmfzLog;
import com.baizhi.cmfz.service.CmfzLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class CmfzLogServiceImpl implements CmfzLogService {
	private Logger logger = LoggerFactory.getLogger(CmfzLogServiceImpl.class);

	@Resource
	private CmfzLogDao cmfzLogDao;
	@Override
	@Transactional(readOnly = true)
	public Map selectCmfzLog(int page, int limit, String name, String type) {
		logger.debug("携带参数"+page+"--"+limit+"--"+name+"--"+type);
//		参数处理
		if(name != null && !"".equals(name)){
			name = "%"+name+"%";
		}else{
			name = null;
		}
		if (type==null || "".equals(type)){
			type = null;
		}

		int offset = (page-1)*limit;
		List<CmfzLog> cmfzLogs = cmfzLogDao.selectLog(offset, limit, name, type);
		int count = cmfzLogDao.totleCount(name, type);
		Map map = new HashMap();
		map.put("data",cmfzLogs);
		map.put("count",count);
		map.put("code",0);
		map.put("msg","");
		return map;
	}
}
